package com.h3c.nem.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.h3c.nem.dto.PmGradeDTO;
import com.h3c.nem.dto.SdAllWorkerDTO;
import com.h3c.nem.dto.TbTeacherDTO;
import com.h3c.nem.dto.mapstruct.NewWorkerDTO;
import com.h3c.nem.entity.SdAllWorker;
import com.h3c.nem.entity.TbOfferStudy;
import com.h3c.nem.entity.TbOfferWorker;
import com.h3c.nem.enums.IdTypeEnum;
import com.h3c.nem.mapper.SdAllWorkerMapper;
import com.h3c.nem.service.CommService;
import com.h3c.nem.service.ISdAllWorkerService;
import com.h3c.nem.service.ITbOfferStudyService;
import com.h3c.nem.service.ITbTeacherService;
import com.h3c.nem.utils.CommonUtil;
import com.h3c.nem.utils.DateUtil;
import com.h3c.nem.utils.InitExampleOrderByUtils;
import com.h3c.nem.vo.SdAllWorkerVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * Copyright (C), 2020-2020, h3c
 * FileName: SdAllWorkerServiceImpl
 *
 * @Author: l22886
 * @Date: 2022-01-19
 * Description: sd_all_worker serviceImpl
 * Version: 1.0
 */
@Slf4j
@Service
public class SdAllWorkerServiceImpl extends ServiceImpl<SdAllWorkerMapper, SdAllWorker> implements ISdAllWorkerService {

    @Resource
    private SdAllWorkerMapper sdAllWorkerMapper;
    @Resource
    private ITbOfferStudyService iTbOfferStudyService;
    @Resource
    private ITbTeacherService tbTeacherService;

    @Resource
    private CommService commService;

    /**
     * @title: selectFuzzyByDto
     * @description: 模糊查询操作
     * @params: [ dto ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public List<SdAllWorkerDTO> selectFuzzyByDto(SdAllWorkerDTO dto) {
        //List<SdAllWorker> list = sdAllWorkerMapper.selectByExample(initFuzzyExample(dto));
        List<SdAllWorker> list = sdAllWorkerMapper.queryListByFuzzy(JSONObject.parseObject(JSONObject.toJSONString(dto), SdAllWorker.class));
        return JSONArray.parseArray(JSONArray.toJSONString(list), SdAllWorkerDTO.class);
    }

    /**
     * @title: selectByDto
     * @description: 精确查询操作
     * @params: [ dto ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public List<SdAllWorkerDTO> selectByDto(SdAllWorkerDTO dto) {
        //List<SdAllWorker> list = sdAllWorkerMapper.selectByExample(initExample(dto));
        List<SdAllWorker> list = sdAllWorkerMapper.queryList(JSONObject.parseObject(JSONObject.toJSONString(dto), SdAllWorker.class));
        return JSONArray.parseArray(JSONArray.toJSONString(list), SdAllWorkerDTO.class);
    }

    /**
     * @title: insertDto
     * @description: 插入操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public Integer insertDto(SdAllWorkerDTO dto) {
        //if (null == dto.getId() || "".equals(dto.getId())) {
        //    String pkId = IdWorker.nextId() + "";
        //    dto.setId(pkId);
        //}
        return sdAllWorkerMapper.insertSdAllWorker(JSONObject.parseObject(JSON.toJSONString(dto), SdAllWorker.class));
    }

    /**
     * @title: updateDto
     * @description: 修改操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public Integer updateDto(SdAllWorkerDTO dto) {
        //if (null != dto && null != dto.getId() && !"".equals(dto.getId())) {
        return sdAllWorkerMapper.updateSdAllWorker(JSONObject.parseObject(JSON.toJSONString(dto), SdAllWorker.class));
        //return sdAllWorkerMapper.updateByPrimaryKey(JSONObject.parseObject(JSON.toJSONString(dto), SdAllWorker.class));
        //} else {
        //    return 0;
        //}
    }

    /**
     * @title: deleteDto
     * @description: 删除操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    @Override
    public Integer deleteDto(SdAllWorkerDTO dto) {
        //if (null != dto && null != dto.getId() && !"".equals(dto.getId())) {
        return sdAllWorkerMapper.deleteSdAllWorker(JSONObject.parseObject(JSON.toJSONString(dto), SdAllWorker.class));
        //return sdAllWorkerMapper.deleteByPrimaryKey(dto.getId());
        //} else {
        //    return 0;
        //}
    }


    /**
     * @title: initFuzzyExample
     * @description: 初始化 模糊查询 example
     * @params: [ dto ]
     * @return: tk.mybatis.mapper.entity.Example
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    private Example initFuzzyExample(SdAllWorkerDTO dto) {
        Example example = InitExampleOrderByUtils.initExampleOrderBy(SdAllWorker.class, dto.getOrderBy());
        Example.Criteria criteriaName = example.createCriteria();
        if (null != dto) {
            if (null != dto.getWorkerId() && !"".equals(dto.getWorkerId())) {
                criteriaName.andLike("WorkerId", "%" + dto.getWorkerId() + "%");
            }
            if (null != dto.getWorkerName() && !"".equals(dto.getWorkerName())) {
                criteriaName.andLike("WorkerName", "%" + dto.getWorkerName() + "%");
            }
            if (null != dto.getDept1id() && !"".equals(dto.getDept1id())) {
                criteriaName.andLike("Dept1id", "%" + dto.getDept1id() + "%");
            }
            if (null != dto.getDept2id() && !"".equals(dto.getDept2id())) {
                criteriaName.andLike("Dept2id", "%" + dto.getDept2id() + "%");
            }
            if (null != dto.getDept3id() && !"".equals(dto.getDept3id())) {
                criteriaName.andLike("Dept3id", "%" + dto.getDept3id() + "%");
            }
            if (null != dto.getDept4id() && !"".equals(dto.getDept4id())) {
                criteriaName.andLike("Dept4id", "%" + dto.getDept4id() + "%");
            }
            if (null != dto.getDirectDeptId() && !"".equals(dto.getDirectDeptId())) {
                criteriaName.andLike("DirectDeptId", "%" + dto.getDirectDeptId() + "%");
            }
            if (null != dto.getPostType() && !"".equals(dto.getPostType())) {
                criteriaName.andLike("PostType", "%" + dto.getPostType() + "%");
            }
            if (null != dto.getPostLevel() && !"".equals(dto.getPostLevel())) {
                criteriaName.andLike("PostLevel", "%" + dto.getPostLevel() + "%");
            }
            if (null != dto.getPostTypeLevel() && !"".equals(dto.getPostTypeLevel())) {
                criteriaName.andLike("PostTypeLevel", "%" + dto.getPostTypeLevel() + "%");
            }
            if (null != dto.getJobType() && !"".equals(dto.getJobType())) {
                criteriaName.andLike("JobType", "%" + dto.getJobType() + "%");
            }
            if (null != dto.getJobLevel() && !"".equals(dto.getJobLevel())) {
                criteriaName.andLike("JobLevel", "%" + dto.getJobLevel() + "%");
            }
            if (null != dto.getJobLevelName() && !"".equals(dto.getJobLevelName())) {
                criteriaName.andLike("JobLevelName", "%" + dto.getJobLevelName() + "%");
            }
            if (null != dto.getJobTypeLevel() && !"".equals(dto.getJobTypeLevel())) {
                criteriaName.andLike("JobTypeLevel", "%" + dto.getJobTypeLevel() + "%");
            }
            if (null != dto.getSyncTime() && !"".equals(dto.getSyncTime())) {
                criteriaName.andLike("SyncTime", "%" + dto.getSyncTime() + "%");
            }
            if (null != dto.getEmail() && !"".equals(dto.getEmail())) {
                criteriaName.andLike("Email", "%" + dto.getEmail() + "%");
            }
            if (null != dto.getDomainAccount() && !"".equals(dto.getDomainAccount())) {
                criteriaName.andLike("DomainAccount", "%" + dto.getDomainAccount() + "%");
            }
            if (null != dto.getLockFlag() && !"".equals(dto.getLockFlag())) {
                criteriaName.andLike("LockFlag", "%" + dto.getLockFlag() + "%");
            }
            if (null != dto.getDisplayName() && !"".equals(dto.getDisplayName())) {
                criteriaName.andLike("DisplayName", "%" + dto.getDisplayName() + "%");
            }
            if (null != dto.getLeaderLevel() && !"".equals(dto.getLeaderLevel())) {
                criteriaName.andLike("LeaderLevel", "%" + dto.getLeaderLevel() + "%");
            }
            if (null != dto.getJoinDate() && !"".equals(dto.getJoinDate())) {
                criteriaName.andLike("JoinDate", "%" + dto.getJoinDate() + "%");
            }
            if (null != dto.getAge() && !"".equals(dto.getAge())) {
                criteriaName.andLike("Age", "%" + dto.getAge() + "%");
            }
        }
        return example;
    }

    /**
     * @title: initExample
     * @description: 初始化 精确查询 example
     * @params: [ dto ]
     * @return: tk.mybatis.mapper.entity.Example
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    private Example initExample(SdAllWorkerDTO dto) {
        Example example = InitExampleOrderByUtils.initExampleOrderBy(SdAllWorker.class, dto.getOrderBy());
        Example.Criteria criteriaName = example.createCriteria();
        if (null != dto) {
            if (null != dto.getWorkerId() && !"".equals(dto.getWorkerId())) {
                criteriaName.andEqualTo("WorkerId", dto.getWorkerId());
            }
            if (null != dto.getWorkerName() && !"".equals(dto.getWorkerName())) {
                criteriaName.andEqualTo("WorkerName", dto.getWorkerName());
            }
            if (null != dto.getDept1id() && !"".equals(dto.getDept1id())) {
                criteriaName.andEqualTo("Dept1id", dto.getDept1id());
            }
            if (null != dto.getDept2id() && !"".equals(dto.getDept2id())) {
                criteriaName.andEqualTo("Dept2id", dto.getDept2id());
            }
            if (null != dto.getDept3id() && !"".equals(dto.getDept3id())) {
                criteriaName.andEqualTo("Dept3id", dto.getDept3id());
            }
            if (null != dto.getDept4id() && !"".equals(dto.getDept4id())) {
                criteriaName.andEqualTo("Dept4id", dto.getDept4id());
            }
            if (null != dto.getDirectDeptId() && !"".equals(dto.getDirectDeptId())) {
                criteriaName.andEqualTo("DirectDeptId", dto.getDirectDeptId());
            }
            if (null != dto.getPostType() && !"".equals(dto.getPostType())) {
                criteriaName.andEqualTo("PostType", dto.getPostType());
            }
            if (null != dto.getPostLevel() && !"".equals(dto.getPostLevel())) {
                criteriaName.andEqualTo("PostLevel", dto.getPostLevel());
            }
            if (null != dto.getPostTypeLevel() && !"".equals(dto.getPostTypeLevel())) {
                criteriaName.andEqualTo("PostTypeLevel", dto.getPostTypeLevel());
            }
            if (null != dto.getJobType() && !"".equals(dto.getJobType())) {
                criteriaName.andEqualTo("JobType", dto.getJobType());
            }
            if (null != dto.getJobLevel() && !"".equals(dto.getJobLevel())) {
                criteriaName.andEqualTo("JobLevel", dto.getJobLevel());
            }
            if (null != dto.getJobLevelName() && !"".equals(dto.getJobLevelName())) {
                criteriaName.andEqualTo("JobLevelName", dto.getJobLevelName());
            }
            if (null != dto.getJobTypeLevel() && !"".equals(dto.getJobTypeLevel())) {
                criteriaName.andEqualTo("JobTypeLevel", dto.getJobTypeLevel());
            }
            if (null != dto.getSyncTime() && !"".equals(dto.getSyncTime())) {
                criteriaName.andEqualTo("SyncTime", dto.getSyncTime());
            }
            if (null != dto.getEmail() && !"".equals(dto.getEmail())) {
                criteriaName.andEqualTo("Email", dto.getEmail());
            }
            if (null != dto.getDomainAccount() && !"".equals(dto.getDomainAccount())) {
                criteriaName.andEqualTo("DomainAccount", dto.getDomainAccount());
            }
            if (null != dto.getLockFlag() && !"".equals(dto.getLockFlag())) {
                criteriaName.andEqualTo("LockFlag", dto.getLockFlag());
            }
            if (null != dto.getDisplayName() && !"".equals(dto.getDisplayName())) {
                criteriaName.andEqualTo("DisplayName", dto.getDisplayName());
            }
            if (null != dto.getLeaderLevel() && !"".equals(dto.getLeaderLevel())) {
                criteriaName.andEqualTo("LeaderLevel", dto.getLeaderLevel());
            }
            if (null != dto.getJoinDate() && !"".equals(dto.getJoinDate())) {
                criteriaName.andEqualTo("JoinDate", dto.getJoinDate());
            }
            if (null != dto.getAge() && !"".equals(dto.getAge())) {
                criteriaName.andEqualTo("Age", dto.getAge());
            }
        }
        return example;
    }

    @Override
    public List<SdAllWorkerVO> searchWorker(String keyword) {
        PageHelper.startPage(1, 20);
        QueryWrapper<SdAllWorker> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("worker_id","worker_name", "display_name");
        int i = CommonUtil.judgeStr(keyword);
        if (i == 1) {
            queryWrapper.like("worker_id", "%" + keyword + "%").orderByAsc("worker_id");
        } else if (i == 2) {
            queryWrapper.like("display_name", "%" + keyword + "%").orderByAsc("worker_id");
        } else if (i == 3) {
            queryWrapper.like("worker_name", "%" + keyword + "%").orderByAsc("worker_id");
        } else {
            return null;
        }
        List<SdAllWorker> workerList = list(queryWrapper);
//        List<SdAllWorker> workerList = list(new QueryWrapper<SdAllWorker>()
//                .like("worker_id", "%" + keyword + "%").or()
//                .like("display_name", "%" + keyword + "%").or()
//                .like("worker_name", "%" + keyword + "%").orderByAsc("worker_id"));
        if (workerList.size() == 0 && i == 1 && keyword.length() == 5) {
            Map<String, String> map = commService.queryCooperativeWorker(keyword);
            if (map != null) {
                SdAllWorker sdAllWorker = new SdAllWorker();
                sdAllWorker.setWorkerId(map.get("emp_code"));
                sdAllWorker.setWorkerName(map.get("emp_name"));
                workerList.add(sdAllWorker);

                //是合作员工，同时加入sdAllWorker
                sdAllWorker.setDomainAccount(map.get("domain_account"));
                String directDeptId = "";
                if (!StringUtils.isEmpty(map.get("dept1_code"))) {
                    sdAllWorker.setDept1id(Integer.parseInt(map.get("dept1_code")));
                    directDeptId = map.get("dept1_code");
                }
                if (!StringUtils.isEmpty(map.get("dept2_code"))) {
                    sdAllWorker.setDept2id(Integer.parseInt(map.get("dept2_code")));
                    directDeptId = map.get("dept2_code");
                }
                if (!StringUtils.isEmpty(map.get("dept3_code"))) {
                    sdAllWorker.setDept3id(Integer.parseInt(map.get("dept3_code")));
                    directDeptId = map.get("dept3_code");
                }
                if (!StringUtils.isEmpty(map.get("dept4_code"))) {
                    sdAllWorker.setDept4id(Integer.parseInt(map.get("dept4_code")));
                    directDeptId = map.get("dept3_code");
                }
                sdAllWorker.setDirectDeptId(Integer.parseInt(directDeptId));
                if (!StringUtils.isEmpty(map.get("display_name"))) {
                    sdAllWorker.setDisplayName(map.get("display_name"));
                }
                if (!StringUtils.isEmpty(map.get("email"))) {
                    sdAllWorker.setEmail(map.get("email"));
                }
                sdAllWorker.setSyncTime(new Date());
                sdAllWorker.setWorkerType(2);//合作员工
                sdAllWorkerMapper.insertSdAllWorker(sdAllWorker);
                commService.addAllWorkerDoToLocalCache(map.get("emp_code"), sdAllWorker);
                log.info("加入合作员工：" + map.get("emp_code") + "至人员总表。");

            }
        }
        return JSONArray.parseArray(JSONObject.toJSONString(workerList), SdAllWorkerVO.class);
    }

    @Override
    public List<NewWorkerDTO> getNewWorker(Date date) {
        QueryWrapper<SdAllWorker> queryWrapper = new QueryWrapper<>();
        queryWrapper.gt("tw.create_time", date);
        queryWrapper.le("tw.create_time", new Date());
        queryWrapper.orderByAsc("tw.create_time");
        List<Map<String, Object>> sdAllWorkers = sdAllWorkerMapper.getNewWorker(queryWrapper);
        List<NewWorkerDTO> result = new ArrayList<>();
        for (Map<String, Object> record : sdAllWorkers) {
            NewWorkerDTO newWorkerDTO = JSON.parseObject(JSON.toJSONString(record), NewWorkerDTO.class);
            result.add(newWorkerDTO);
        }
        return result;
    }

    public void updateAllWorkerOfOfferWorker(TbOfferWorker offerWorker, String[] codes, String emailAddress, String samAccount) {
        SdAllWorker sdAllWorker = new SdAllWorker();
        sdAllWorker.setWorkerId(offerWorker.getRegularWorkerId());
        sdAllWorker.setWorkerName(offerWorker.getWorkerName());
        if (codes.length >= 2) {
            sdAllWorker.setDept1id(Integer.valueOf(codes[1]));
        }
        if (codes.length >= 3) {
            sdAllWorker.setDept2id(Integer.valueOf(codes[2]));
        }
        if (codes.length >= 4) {
            sdAllWorker.setDept3id(Integer.valueOf(codes[3]));
        }
        if (codes.length >= 5) {
            sdAllWorker.setDept4id(Integer.valueOf(codes[4]));
        }
        Integer directDeptId = Integer.valueOf(codes[codes.length - 1]);
        sdAllWorker.setDirectDeptId(directDeptId);
//        sdAllWorker.setPostType();
//        sdAllWorker.setPostLevel();
//        sdAllWorker.setPostTypeLevel();
//        sdAllWorker.setJobType();
        sdAllWorker.setJobLevel(offerWorker.getJobLevel());
//        sdAllWorker.setJobLevelName();
//        sdAllWorker.setJobTypeLevel();
        sdAllWorker.setSyncTime(new Date());
        sdAllWorker.setEmail(emailAddress);
        sdAllWorker.setDomainAccount(samAccount);
//        sdAllWorker.setLockFlag();
        sdAllWorker.setDisplayName(offerWorker.getNamePinyin());
//        sdAllWorker.setLeaderLevel();
        sdAllWorker.setJoinDate(offerWorker.getContractBeginDate());

        sdAllWorker.setAge(DateUtil.getAge(offerWorker.getBirthday()));
        sdAllWorker.setWorkCity(offerWorker.getWorkCity());
        if (Objects.equals(offerWorker.getCertType(), IdTypeEnum.ID_CARD)
                && !StringUtils.isEmpty(offerWorker.getCertNo())) {
            String certNo = offerWorker.getCertNo();
            String certOfTopSix = certNo.substring(certNo.length() - 6);
            sdAllWorker.setCertificateNoTopSix(certOfTopSix);
        }
        sdAllWorker.setSite(offerWorker.getWorkLocation());
        QueryWrapper<TbOfferStudy> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(TbOfferStudy::getWorkerId, offerWorker.getWorkerId())
                .eq(TbOfferStudy::getIsHighestEducation, true);
        TbOfferStudy study = iTbOfferStudyService.getOne(queryWrapper);
        if (study != null) {
            sdAllWorker.setGraduateSchool(study.getCollegeName());
        }
//        sdAllWorker.setLockAccount();
        sdAllWorker.setWorkerType(1);
        saveOrUpdate(sdAllWorker);
    }


    @Override
    public List<TbTeacherDTO> checkTeacherAbility(List<String> workerIdList){
        String[] periods = CommonUtil.getLastSeasonsByNum(new Date(), 4);
        //获取绩效
        List<PmGradeDTO> pmGradeList = tbTeacherService.getPmGradeList(workerIdList);
        List<PmGradeDTO> pmGradeDTOList = new ArrayList<>();
        pmGradeList.forEach(pmGrade -> {
            if(pmGrade.getEvaluationType()==90){//季度
                pmGradeDTOList.add(pmGrade);
            }
        });
        Map<String, List<PmGradeDTO>> gradeMap = pmGradeDTOList.stream().collect(
                Collectors.groupingBy(pmGradeDTO -> pmGradeDTO.getWorkerId()));
        //获取文化
        List<PmGradeDTO> pmCultureList = tbTeacherService.getPmCultureList(workerIdList);
        Map<String, List<PmGradeDTO>> cultureMap = pmCultureList.stream().collect(
                Collectors.groupingBy(pmGradeDTO -> pmGradeDTO.getWorkerId()));
        //获取奖惩信息
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.YEAR, -2);
        Date twoYearsBefore = calendar.getTime();
        Map<String, String> publishDataMap = tbTeacherService.syncPunishData(twoYearsBefore,new Date());


        Integer i = 0;
        //设置字段
        List<TbTeacherDTO> tbTeacherDTOS = new ArrayList<>();
        for (String workerId : workerIdList) {
            TbTeacherDTO tbTeacherDTO = new TbTeacherDTO();
            tbTeacherDTO.setTeacherId(workerId);

            //设置惩处信息
            if (!CollectionUtils.isEmpty(publishDataMap)) {
                String publishRecord = publishDataMap.get(workerId);
                if (!StringUtils.isEmpty(publishRecord)) {
                    tbTeacherDTO.setLastPunishRecord(publishRecord);
                }
            }
            //设置绩效
            List<PmGradeDTO> gradeList = gradeMap.get(workerId);
            Map<String, String> newGradeMap = new HashMap<>();
            if (!CollectionUtils.isEmpty(gradeList)) {
                StringBuilder gradeStr = new StringBuilder();
                List<String> periodNameList = new ArrayList<>();
                gradeList.forEach(pmGradeDTO -> {
                    periodNameList.add(pmGradeDTO.getGradePeriod());
                    String periodName = pmGradeDTO.getGradePeriod();
                    String kpi = pmGradeDTO.getGradeValue();
                    newGradeMap.put(periodName, kpi);
                });
                for (String s : periods) {
                    if (!StringUtils.isEmpty(newGradeMap.get(s))) {
                        gradeStr.append(s).append(":").append(newGradeMap.get(s)).append(";");
                    } else {
                        gradeStr.append(s).append(":").append("-").append(";");
                    }
                }
                tbTeacherDTO.setLast4kpi(gradeStr.substring(0, gradeStr.length() - 1));
            }
            //设置文化
            List<PmGradeDTO> cultureList = cultureMap.get(workerId);
            Map<String, String> newCultureMap = new HashMap<>();
            if (!CollectionUtils.isEmpty(cultureList)) {
                List<String> periodNameList = new ArrayList();
                StringBuilder cultureStr = new StringBuilder();
                cultureList.forEach(pmGradeDTO -> {
                    String date = pmGradeDTO.getEvaluationBeginDate().split(" ")[0];//2020-10-01;2021-01-01
                    String periodName = CommonUtil.getPeriodName(date);
                    String culture = pmGradeDTO.getEvaluationResult();
                    if (pmGradeDTO.getEvaluationTypeC() == 90) {
                        newCultureMap.put(periodName, culture);
                        periodNameList.add(periodName);
                    }
                });
                for (String s : periods) {
                    if (!StringUtils.isEmpty(newCultureMap.get(s))) {
                        cultureStr.append(s).append(":").append(newCultureMap.get(s)).append(";");
                    } else {
                        cultureStr.append(s).append(":").append("-").append(";");
                    }
                }
                tbTeacherDTO.setLast4culture(cultureStr.substring(0, cultureStr.length() - 1));
            }
            tbTeacherDTOS.add(tbTeacherDTO);
        }
        List<TbTeacherDTO> tbTeacherDTOList = tbTeacherService.checkTeacherFlag(tbTeacherDTOS);
        List<TbTeacherDTO> tbTeacherDTOS1 = new ArrayList<>();
        List<String> resId = new ArrayList<>();
        for (TbTeacherDTO tbTeacherDTO : tbTeacherDTOList) {
            if(tbTeacherDTO.getCheckResultFlag()==1){
                resId.add(tbTeacherDTO.getTeacherId());
                tbTeacherDTOS1.add(tbTeacherDTO);
            }
        }
        return tbTeacherDTOS1;
    }

}
